package xyz.ddlnt.servicemq.listener;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import xyz.ddlnt.model.dto.UserContentInteractionDTO;
import xyz.ddlnt.servicemq.service.PostHistoryRecordService;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/25 21:08
 */
@Slf4j
@Component
public class PostHistoryRecordListener {
    @Resource
    private PostHistoryRecordService postHistoryRecordService;

    /**
     * 帖子浏览历史数加1
     * @param userContentInteractionDTO
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "post_history_record_plus_one"),
            exchange = @Exchange(name =  "usr.post_history_record"),
            key = "post_history_record_plus_one"
    ))
    public void postHistoryRecordPlusOne(UserContentInteractionDTO userContentInteractionDTO) {
        postHistoryRecordService.postHistoryRecordPlusOne(userContentInteractionDTO);
        log.info("帖子浏览历史数加1");
    }
}
